<?php

class WebErrorResponse extends WebResponse {
	public function __construct($state = null) {
		parent::__construct();
		if (is_null($state)) $state = '500 Internal Server Error';
		$this
			->setState($state)
			->setHeaders(array(
				'Content-Type' => 'text/html'					
			))
			->setBody(
				self::defaultHTMLBodyForState($state));
	}
	
	public static function defaultHTMLBodyForState($state) {
		return <<< EOS
	
			<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
			<html>
				<head>
					<title>$state</title>
				</head>
				<body>
				<h1>$state</h1>
				</body>
			</html>

EOS;
	}

}

?>